﻿using System;
using System.Diagnostics;
using System.Runtime.Serialization;

namespace CSC.Google
{
    /// <summary>
    /// Summary statistics for the page, such as number of JavaScript bytes, number of HTML bytes, etc.
    /// </summary>
    [Serializable]
    public class PageStats
    {
        #region Private Variables
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int numberResources = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int numberHosts = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long totalRequestBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int numberStaticResources = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long htmlResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long textResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long cssResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long imageResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long javascriptResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long flashResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private long otherResponseBytes = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int numberJsResources = 0;
        [OptionalField, DebuggerBrowsable(DebuggerBrowsableState.Never)]
        private int numberCssResources = 0;
        #endregion

        /// <summary>
        /// Number of HTTP resources loaded by the page.
        /// </summary>
        public int NumberResources { get { return numberResources; } }

        /// <summary>
        /// Number of unique hosts referenced by the page.
        /// </summary>
        public int NumberHosts { get { return numberHosts; } }

        /// <summary>
        /// Total size of all request bytes sent by the page.
        /// </summary>
        public long TotalRequestBytes { get { return totalRequestBytes; } }

        /// <summary>
        /// Number of static (that is, cacheable) resources on the page.
        /// </summary>
        public int NumberStaticResources { get { return numberStaticResources; } }

        /// <summary>
        /// Number of uncompressed response bytes for the main HTML document and all iframes on the page.
        /// </summary>
        public long HtmlResponseBytes { get { return htmlResponseBytes; } }

        /// <summary>
        /// Number of uncompressed response bytes for text resources on the page that aren't covered by other statistics; that is, non-HTML, non-script, non-CSS resources.
        /// </summary>
        public long TextResponseBytes { get { return textResponseBytes; } }

        /// <summary>
        /// Number of uncompressed response bytes for CSS resources on the page.
        /// </summary>
        public long CssResponseBytes { get { return cssResponseBytes; } }

        /// <summary>
        /// Number of response bytes for image resources on the page.
        /// </summary>
        public long ImageResponseBytes { get { return imageResponseBytes; } }

        /// <summary>
        /// Number of uncompressed response bytes for JS resources on the page.
        /// </summary>
        public long JavascriptResponseBytes { get { return javascriptResponseBytes; } }

        /// <summary>
        /// Number of response bytes for Flash resources on the page.
        /// </summary>
        public long FlashResponseBytes { get { return flashResponseBytes; } }

        /// <summary>
        /// Number of response bytes for other resources on the page.
        /// </summary>
        public long OtherResponseBytes { get { return otherResponseBytes; } }

        /// <summary>
        /// Number of JavaScript resources referenced by the page.
        /// </summary>
        public int NumberJsResources { get { return numberJsResources; } }

        /// <summary>
        /// Number of CSS resources referenced by the page.
        /// </summary>
        public int NumberCssResources { get { return numberCssResources; } }
    }
}
